home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / graphi2a / graphics.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-09-20  |  10.6 KB  |  430 lines

  1. VERSION 5.00
  2. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
  3. Begin VB.Form Graphics 
  4.    BackColor       =   &H00000000&
  5.    Caption         =   "Graphics"
  6.    ClientHeight    =   8355
  7.    ClientLeft      =   165
  8.    ClientTop       =   735
  9.    ClientWidth     =   9600
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   8355
  12.    ScaleWidth      =   9600
  13.    StartUpPosition =   3  'Windows Default
  14.    Begin VB.Timer Timer7 
  15.       Interval        =   100
  16.       Left            =   8880
  17.       Top             =   1320
  18.    End
  19.    Begin VB.VScrollBar VSbcirc 
  20.       Height          =   1575
  21.       LargeChange     =   2
  22.       Left            =   0
  23.       Max             =   700
  24.       TabIndex        =   2
  25.       Top             =   0
  26.       Visible         =   0   'False
  27.       Width           =   255
  28.    End
  29.    Begin VB.Timer Timer6 
  30.       Interval        =   500
  31.       Left            =   8880
  32.       Top             =   1200
  33.    End
  34.    Begin VB.Timer Timer5 
  35.       Interval        =   100
  36.       Left            =   8880
  37.       Top             =   1080
  38.    End
  39.    Begin VB.Timer Timer4 
  40.       Interval        =   10
  41.       Left            =   8880
  42.       Top             =   960
  43.    End
  44.    Begin VB.Timer Timer3 
  45.       Interval        =   1
  46.       Left            =   8880
  47.       Top             =   840
  48.    End
  49.    Begin VB.Timer Timer2 
  50.       Interval        =   1
  51.       Left            =   8880
  52.       Top             =   720
  53.    End
  54.    Begin VB.Timer Timer1 
  55.       Interval        =   1
  56.       Left            =   8880
  57.       Top             =   600
  58.    End
  59.    Begin MSComDlg.CommonDialog CommonDialog1 
  60.       Left            =   8880
  61.       Top             =   7440
  62.       _ExtentX        =   847
  63.       _ExtentY        =   847
  64.       _Version        =   393216
  65.    End
  66.    Begin VB.PictureBox Picture1 
  67.       BackColor       =   &H80000009&
  68.       Height          =   255
  69.       Left            =   0
  70.       ScaleHeight     =   195
  71.       ScaleWidth      =   195
  72.       TabIndex        =   1
  73.       Top             =   0
  74.       Visible         =   0   'False
  75.       Width           =   255
  76.    End
  77.    Begin VB.Label Label1 
  78.       BackColor       =   &H80000007&
  79.       Height          =   135
  80.       Left            =   9120
  81.       TabIndex        =   0
  82.       Top             =   0
  83.       Width           =   255
  84.    End
  85.    Begin VB.Menu mnuTools 
  86.       Caption         =   "&Tools"
  87.       Begin VB.Menu mnuMarker 
  88.          Caption         =   "&Marker"
  89.       End
  90.       Begin VB.Menu mnuPencil 
  91.          Caption         =   "&Pencil"
  92.       End
  93.       Begin VB.Menu mnuCircle 
  94.          Caption         =   "&Circle"
  95.       End
  96.       Begin VB.Menu mnuLine 
  97.          Caption         =   "&Line"
  98.       End
  99.    End
  100.    Begin VB.Menu mnuback 
  101.       Caption         =   "&Back Ground"
  102.       Begin VB.Menu mnuStyle 
  103.          Caption         =   "Fill &Style"
  104.       End
  105.       Begin VB.Menu MnuFill 
  106.          Caption         =   "&Fill"
  107.       End
  108.    End
  109.    Begin VB.Menu MnuEffects 
  110.       Caption         =   "&Effects"
  111.       Begin VB.Menu mnuStaticC 
  112.          Caption         =   "&Static Color"
  113.       End
  114.       Begin VB.Menu mnuSlide 
  115.          Caption         =   "Static S&lide"
  116.       End
  117.       Begin VB.Menu mnustaticBW 
  118.          Caption         =   "Static &Black"
  119.       End
  120.       Begin VB.Menu mnuStar 
  121.          Caption         =   "St&ar"
  122.       End
  123.       Begin VB.Menu mnuStarBack 
  124.          Caption         =   "Star &Variation"
  125.       End
  126.       Begin VB.Menu mnuRnd 
  127.          Caption         =   "&RandomLines"
  128.       End
  129.       Begin VB.Menu mnucircm 
  130.          Caption         =   "C&ircles (manual)"
  131.       End
  132.       Begin VB.Menu mnuCircles 
  133.          Caption         =   "&Circles"
  134.       End
  135.    End
  136.    Begin VB.Menu mnuColor 
  137.       Caption         =   "&Color"
  138.       Begin VB.Menu mnuPallete 
  139.          Caption         =   "Color&Pallete"
  140.       End
  141.    End
  142.    Begin VB.Menu mnuClear 
  143.       Caption         =   "Clear"
  144.    End
  145.    Begin VB.Menu mnuThumb 
  146.       Caption         =   "&Thumbnail"
  147.    End
  148.    Begin VB.Menu mnupicbox 
  149.       Caption         =   "&Picture Box"
  150.    End
  151.    Begin VB.Menu mnuflash 
  152.       Caption         =   "&Font Flasher"
  153.    End
  154. Attribute VB_Name = "Graphics"
  155. Attribute VB_GlobalNameSpace = False
  156. Attribute VB_Creatable = False
  157. Attribute VB_PredeclaredId = True
  158. Attribute VB_Exposed = False
  159. Option Explicit
  160. Public colorch
  161. Dim gstatic
  162. Dim gstaticBW
  163. Dim gstaticsl
  164. Dim gstar
  165. Dim gstarb
  166. Dim gline
  167. Dim x
  168. Dim y
  169. Dim r
  170. Dim g
  171. Dim b
  172. Dim line2
  173. Dim pencil
  174. Dim circ
  175. Dim drawcirc
  176. Dim circle1
  177. Dim sizecirc
  178. Private Sub Form_Load()
  179. colorch = RGB(255, 255, 255)
  180. gstatic = 0
  181. circle1 = 0
  182. gstaticBW = 0
  183. gstaticsl = 0
  184. gstar = 0
  185. gstarb = 0
  186. gline = 0
  187. line2 = 0
  188. pencil = 0
  189. circ = 0
  190. drawcirc = 0
  191. End Sub
  192. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  193. Graphics.CurrentX = x
  194. Graphics.CurrentY = y
  195. If line2 = 1 Then
  196. Line (Graphics.CurrentX, Graphics.CurrentY)-(x, y), colorch
  197. End If
  198. If circle1 = 1 Then
  199. Circle (x, y), sizecirc, colorch
  200. End If
  201. End Sub
  202. Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
  203. If pencil = 1 Then
  204. Line (Graphics.CurrentX, Graphics.CurrentY)-(x, y), colorch
  205. End If
  206. End Sub
  207. Private Sub mnuCircle_Click()
  208. circle1 = 1
  209. sizecirc = InputBox("What size: 1 to 20", "Circle Size")
  210. sizecirc = sizecirc * 50
  211. End Sub
  212. Private Sub mnuCircles_Click()
  213. circ = 1
  214. End Sub
  215. Private Sub mnucircm_Click()
  216. VSbcirc.Visible = Not VSbcirc.Visible
  217. End Sub
  218. Private Sub mnuClear_Click()
  219. Graphics.Cls
  220. circ = 0
  221. gstatic = 0
  222. gstaticBW = 0
  223. gstaticsl = 0
  224. gstar = 0
  225. gstarb = 0
  226. gline = 0
  227. End Sub
  228. Private Sub MnuFill_Click()
  229. On Error GoTo error
  230.     CommonDialog1.Action = 3
  231.     Graphics.BackColor = CommonDialog1.Color
  232. Exit Sub
  233. error:
  234.     MsgBox "Cancelled by user."
  235. End Sub
  236. Private Sub mnuflash_Click()
  237. Flash.Show
  238. Unload Graphics
  239. End Sub
  240. Private Sub mnuLine_Click()
  241. line2 = 1
  242. End Sub
  243. Public Sub mnuPallete_Click()
  244. On Error GoTo error
  245.     CommonDialog1.Action = 3
  246.     colorch = CommonDialog1.Color
  247.     Label1.BackColor = colorch
  248. Exit Sub
  249. error:
  250.     MsgBox "Cancelled by user."
  251. End Sub
  252. Private Sub mnupicbox_Click()
  253.     Picture1.Width = Graphics.ScaleWidth
  254.     Picture1.Height = Graphics.ScaleHeight
  255.     Picture1.Visible = Not Picture1.Visible
  256. End Sub
  257. Private Sub mnuRnd_Click()
  258.     gline = 1
  259. End Sub
  260. Private Sub mnuSlide_Click()
  261.     gstaticsl = 1
  262. End Sub
  263. Private Sub mnuStar_Click()
  264.     gstar = 1
  265. End Sub
  266. Private Sub mnuStarBack_Click()
  267.     gstarb = 1
  268. End Sub
  269. Private Sub mnustaticBW_Click()
  270.     gstaticBW = 1
  271. End Sub
  272. Private Sub mnuStaticC_Click()
  273.     gstatic = 1
  274. End Sub
  275. Private Sub mnuStyle_Click()
  276. Dim chose2
  277. Dim return2
  278. return2 = Chr(13) + Chr(10)
  279. chose2 = InputBox("What style do you want:" + return2 + _
  280.     "0 = Solid" + return2 + _
  281.     "1 = Transparent" + return2 + "2 = Horizontal Lines" _
  282.     + return2 + "3 = Vertical Lines" + return2 + "4 = Upward Diagonal" _
  283.     + return2 + "5 = Downward Diagonal" + return2 + "6 = Crosshatch" _
  284.     + return2 + "7 = Diagonal Crosshatch", "Choose Fill Style", 1)
  285. If vbOK Then
  286.         x = Graphics.ScaleWidth
  287.         y = Graphics.ScaleHeight
  288.     Graphics.FillColor = colorch
  289.     Graphics.FillStyle = Val(chose2)
  290.     'Graphics.Line (100, 80)-Step(x, y), RGB(0, 0, 0), B
  291.    Else
  292.   Exit Sub
  293.  End If
  294. End Sub
  295. Private Sub mnuThumb_Click()
  296.     thumbnail.Show
  297. End Sub
  298. Private Sub Timer1_Timer()
  299. Dim r, g, b
  300. Dim x, y
  301. Dim counter
  302. If gstatic = 1 Then
  303.     For counter = 1 To 100 Step 1
  304.         r = Rnd * 255
  305.         g = Rnd * 255
  306.         b = Rnd * 255
  307.         x = Rnd * Graphics.ScaleWidth
  308.         y = Rnd * Graphics.ScaleHeight
  309.         Graphics.PSet (x, y), RGB(r, g, b)
  310.     Next
  311. End If
  312. End Sub
  313. Private Sub Timer2_Timer()
  314. Dim x, y
  315. Dim counter
  316. If gstaticBW = 1 Then
  317.     For counter = 1 To 1000 Step 1
  318.         
  319.         x = Rnd * Graphics.ScaleWidth
  320.         y = Rnd * Graphics.ScaleHeight
  321.         Graphics.PSet (x, y), RGB(0, 0, 0)
  322.     Next
  323. End If
  324. End Sub
  325. Private Sub Timer3_Timer()
  326. Dim r, g, b
  327. 'Dim X, Y
  328. Dim counter
  329. If gstaticsl = 1 Then
  330.     For counter = 1 To 10000 Step 1
  331.         r = Rnd * 255
  332.         g = Rnd * 255
  333.         b = Rnd * 255
  334.         'X = Rnd * Graphics.ScaleWidth
  335.         'Y = Rnd * Graphics.ScaleHeight
  336.         Graphics.PSet Step(1, 10), RGB(r, g, b)
  337.             If CurrentX >= Graphics.ScaleHeight Then
  338.             CurrentX = Rnd * Graphics.ScaleHeight
  339.         End If
  340.             If CurrentY >= Graphics.ScaleWidth Then
  341.             CurrentY = Rnd * Graphics.ScaleWidth
  342.         End If
  343.      
  344.      Next
  345.   End If
  346. End Sub
  347. Private Sub Timer4_Timer()
  348. Dim r, g, b, e, f
  349. Dim x, y
  350. Dim counter
  351. If gstar = 1 Then
  352.     For counter = 1 To 100 Step 1
  353.         r = Rnd * 255
  354.         g = Rnd * 255
  355.         b = Rnd * 255
  356.         x = Rnd * Graphics.ScaleWidth
  357.         y = Rnd * Graphics.ScaleHeight
  358.         e = Graphics.ScaleWidth / 2
  359.         f = Graphics.ScaleHeight / 2
  360.         Line (e, f)-(x, y), RGB(r, g, b)
  361.     Next
  362. End If
  363. End Sub
  364. Private Sub Timer5_Timer()
  365. Dim r, g, b
  366. Dim x, y
  367. Dim counter
  368. If gstarb = 1 Then
  369.     For counter = 1 To 100 Step 1
  370.         r = Rnd * 255
  371.         g = Rnd * 255
  372.         b = Rnd * 255
  373.         x = Rnd * Graphics.ScaleWidth
  374.         y = Rnd * Graphics.ScaleHeight
  375.         Line (0, 0)-(x, y), RGB(r, g, b)
  376.     Next
  377. End If
  378. End Sub
  379. Private Sub Timer6_Timer()
  380. Dim r, g, b
  381. Dim x, y
  382. Dim counter
  383. If gline = 1 Then
  384.     For counter = 1 To 100 Step 1
  385.         r = Rnd * 255
  386.         g = Rnd * 255
  387.         b = Rnd * 255
  388.         x = Rnd * Graphics.ScaleWidth
  389.         y = Rnd * Graphics.ScaleHeight
  390.         Line -(x, y), RGB(r, g, b)
  391.      Next
  392.       End If
  393. End Sub
  394. Private Sub Timer7_Timer()
  395. Dim counter As Integer
  396. If circ = 1 Then
  397. For counter = 1 To 200 Step 1
  398. 'Static lastcirc
  399.     Dim x, y, radius
  400.     Dim r, g, b
  401.     r = Rnd * 255
  402.     g = Rnd * 255
  403.     b = Rnd * 255
  404.     x = Graphics.ScaleWidth / 2
  405.     y = Graphics.ScaleHeight / 2
  406.     'If lastcirc > VSbcirc Then Graphics.Cls
  407.     Graphics.DrawStyle = drawcirc
  408.     Graphics.Circle (x, y), Rnd * 7000, RGB(r, g, b)
  409.     'lastcirc = VSbcirc.Value
  410.     Next
  411.     End If
  412. End Sub
  413. Private Sub VSbcirc_Change()
  414. Static lastcirc
  415.     Dim x, y, radius
  416.     Dim r, g, b
  417.     r = Rnd * 255
  418.     g = Rnd * 255
  419.     b = Rnd * 255
  420.     x = Graphics.ScaleWidth / 2
  421.     y = Graphics.ScaleHeight / 2
  422.     'If lastcirc > VSbcirc Then Graphics.Cls
  423.     Graphics.Circle (x, y), VSbcirc.Value * 10, RGB(r, g, b)
  424.     lastcirc = VSbcirc.Value
  425.         
  426. End Sub
  427. Private Sub VSbcirc_Scroll()
  428. VSbcirc_Change
  429. End Sub
  430.